
const getPropValue = require('../common/utility.js').getPropValue;

// __d(...)的第3个参数所表示的数组
function get_dependencies_list_in___d_call(ast){
	var the_array_ast = getPropValue(ast,['expression','arguments',2]);
	if(the_array_ast && the_array_ast.type==='ArrayExpression' && the_array_ast.elements && the_array_ast.elements.push){
		var arr = [];
		var elements = the_array_ast.elements;
		for(var i=0; i<elements.length; i++){
			var itm = (elements[i]||{}).value;
			if( (typeof itm==='number') && (!isNaN(itm)) ){
				arr.push(itm);
			} else {
				var error_1 = '错误：数组值不是正常数字  (when:获取__d(...)中依赖项)';
				console.log(error_1);
				return error_1;
			}
		}
		if(arr.length===0){
			//console.log('依赖0个模块');
		}
		return arr;
	} else {
		var error_2 = '错误：数组ast解析出错  (when:获取__d(...)中依赖项)';
		console.log(error_2);
		return error_2;
	}
}

module.exports = get_dependencies_list_in___d_call;

